#ifndef FSMFORMAT_H
#define FSMFORMAT_H
#pragma pack(push,1)


//------------------------------------------------------------------------
//	FSM commands
//------------------------------------------------------------------------
typedef enum
{
	FSMCMD_END = 0,

	FSMCMD_ACCEPTLINK,
	FSMCMD_BREAKLINK,
	FSMCMD_CHANGEBEHAVIOR,
	FSMCMD_CREATLINK,
	FSMCMD_ERROR,
	FSMCMD_EVENT,
	FSMCMD_EXECUTE,
	FSMCMD_IFFLAGS,
	FSMCMD_IFRANDOM,
	FSMCMD_IFLINK,
	FSMCMD_SENDEVENT,
	FSMCMD_SETANIMATION,
	FSMCMD_SETFLAGS,
	FSMCMD_TRANSITION,

} EFSMCommandID;

//-----------------------------------------------------------------
//	flags for transition command
//-----------------------------------------------------------------
#define	FSMTRANSITION_STATEEXIT			(1<<0)

//-----------------------------------------------------------------
//	flags for SetAnimation command
//-----------------------------------------------------------------
#define	FSMSETANIM_BLENDING				(1<<0)
#define	FSMSETANIM_REPEAT				(1<<1)
#define	FSMSETANIM_REVERSE				(1<<2)
#define	FSMSETANIM_KEEPFRAME			(1<<3)

//------------------------------------------------------------------------
//	an event handler command
//------------------------------------------------------------------------
typedef struct
{
	EFSMCommandID	command : 8;
	u32				length  : 8;
	u32				user1   : 8;
	u32				user2   : 8;

} SFSMCommand;

//------------------------------------------------------------------------
//	an FSM state
//------------------------------------------------------------------------
class CFSMState
{
public:
	HASH			name;
	u32				behaviors;

	bool			isOrphan      : 1;
	bool			hasStateEnter : 1;
	bool			hasStateExit  : 1;
	bool			hasStateRun   : 1;

	const char		*nameString;
	const CFSMState	*parent;
	CStaticHashList	events;

	// CHashListItem	eventItems[];
	// SFSMCommand	eventHandlers[];
};

//------------------------------------------------------------------------
//	an FSM definition
//------------------------------------------------------------------------
class CFSMDef
{
public:
	HASH			name;
	HASH			type;
	HASH			parentName;
	HASH			initialState;
	const char		*nameString;
	const CFSMDef	*parent;
	CStaticHashList	states;
	CStaticHashList	dictionary;

	// CHashListItem	stateItems[];
	// CFSMState		states[];
	// CHashListItem	dictionaryItems[];
	// char			dictionary[];
};

#pragma pack(pop)
#endif
